package com.redis.redisson;

import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * 作者: LCG
 * 日期: 2020/7/7 02:17
 * 描述:
 */
@RestController
public class RedissonController {

    @Autowired
    private RedissonClient redissonClient;

    private static int count=0;


    @RequestMapping("redisson")
    public void test00(){
        RLock yy = redissonClient.getLock("YY");

        yy.lock(10,TimeUnit.SECONDS);

        count=count+1;

        yy.unlock();

    }


    @RequestMapping("getCount")
    public int yyy(){
        return count;
    }

    @RequestMapping
    public void test03(){
        
    }

}
